import { getCustomerInfo } from "@/server"
import { useRequest } from "ahooks"
import { useEffect } from "react"
import { UseDispatch, useDispatch } from "react-redux"
import { setCustomerInfo } from "@/store/CustomerStore"



const useLoadCustomerInfo = ()=>{
    const dispatch = useDispatch()
    const {run } = useRequest(()=>{
        return getCustomerInfo()
    },{
        manual:true,
        onSuccess(res){
            dispatch(setCustomerInfo({head:res.avatar,chatid:res.account,nickname:res.nickname}))
        }
    })
    useEffect(()=>{
        run()
    },[])
  
}

export default useLoadCustomerInfo